package threadException;

import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;

public class ThreadException2 {
    /**
     *
     * @param args
     * @throws InterruptedException
     */
    public static void main(String[] args) throws InterruptedException {
        System.out.println("主线程开始");
        new Thread(() -> {
            System.out.println("子线程1开始");
            int i = 1/0;
            System.out.println("子线程1结束");
        }).start();
        TimeUnit.SECONDS.sleep(2);
        new Thread(new FutureTask<String>(() -> {
            System.out.println("子线程2开始");
            int i = 1/0;
            System.out.println("子线程2结束");
            return "子线程二";
        })).start();
        TimeUnit.SECONDS.sleep(2);
        System.out.println("主线程截至");
    }
}
